package com.feng.boot.datajpa.controller;

import com.feng.boot.datajpa.entity.User;
import com.feng.boot.datajpa.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Lee
 */
@RestController
public class UserController {

    @Autowired
    private UserRepository  userRepository;

//    @ApiOperation(value = "/user/{id}",notes = "根据 Id 获取 User")
    @GetMapping("/user/{id}")
    public User getUserById(@PathVariable("id") Integer id) {
        return userRepository.findOne(id);
    }

    @PostMapping("/user/save")
    public User save(@RequestBody User user){
        return userRepository.save(user);
    }

}
